<?php

if (!defined('IN_DISCUZ')) {
    exit('Access Denied');
}
global $_G;
error_reporting(0);

require_once libfile('function/cache');
loadcache('ainuodata');
$mysiteBM = currentlang();
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Appbyme') > 0) {
    $Appbyme = true;
}
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') > 0) {
    $WxApp = true;
}
if ($_G['cache']['plugin']['qu_app']['diybotnav']) {
    $openbotnav = true;
}
if ($_G['cache']['plugin']['qu_app']['app_user'] && $Appbyme) {
    $isxiaoyunuser = true;
}
$openbotnavcon = $_G['cache']['plugin']['qu_app']['botnavcon'];
$pagestyle = $_G['cache']['plugin']['qu_app']['pagestyle'];
$cache = $_G['cache']['ainuodata'];
if ($cache && TIMESTAMP - $cache['cachetime'] < 36000) {
    $configData = $cache['data'];
    $leftnav = $cache['leftnav'];
    $quicknav = $cache['quicknav'];
    $updatecache = false;
} else {
    $configData = get_configData();
    $leftnav = get_leftnav();
    $quicknav = get_quicknav();
    $updatecache = true;
}
if ($updatecache) {
    $cache_data = array('cachetime' => TIMESTAMP, 'data' => $configData, 'annc' => $annclist, 'leftnav' => $leftnav, 'quicknav' => $quicknav, 'zhiding' => $datazd, 'moduleid' => $datamodule, 'topnav' => $topnav, 'newad' => $dataad);
    savecache('ainuodata', $cache_data);
}
function get_configData()
{
    $query = DB::query('SELECT * from ' . DB::table('qu_appnew') . '');
    DB::fetch($query);
    foreach (DB::fetch($query) as $key => $list) {
        $data[$key] = $list;
    }
    return $data;
}
function get_leftnav()
{
    $query = DB::query('SELECT * FROM ' . DB::table('qu_appnav') . ' ORDER BY displayorder ASC');
    while ($list = DB::fetch($query)) {
        $data[] = $list;
    }
    return $data;
}
function get_quicknav()
{
    $query = DB::query('SELECT * FROM ' . DB::table('qu_appquicknav') . ' ORDER BY displayorder ASC');
    while ($list = DB::fetch($query)) {
        $data[] = $list;
    }
    return $data;
}
function aremaintime($time)
{
    $days = intval($time / 86400);
    $time -= $days * 86400;
    $hours = intval($time / 3600);
    $time -= $hours * 3600;
    $minutes = intval($time / 60);
    $time -= $minutes * 60;
    $seconds = $time;
    return array(0 => (int) $days, 1 => (int) $hours, 2 => (int) $minutes, 3 => (int) $seconds);
}